﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace OPCTreeMonitor.InterfaceWindow
{
    /// <summary>
    /// InterfaceAddFileName.xaml 的交互逻辑
    /// </summary>
    public partial class InterfaceAddFileName : Window
    {
        public event EventHandler<FileNameAddedEventArgs> FileNameAdded;

        public InterfaceAddFileName()
        {
            InitializeComponent();
        }

        private void btn_Add_Click(object sender, RoutedEventArgs e)
        {
            string fileName = txt_FileName.Text.Trim();
            string groupName = txt_GroupName.Text.Trim();

            if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(groupName))
            {
                MessageBox.Show("文件名和组名不能为空，请输入有效的信息。");
                return;
            }

            // 触发事件，传递文件名和组名
            FileNameAdded?.Invoke(this, new FileNameAddedEventArgs { FileName = fileName, GroupName = groupName });
            this.Close();
        }
    }

    public class FileNameAddedEventArgs : EventArgs
    {
        public string FileName { get; set; }
        public string GroupName { get; set; }
    }
}
